//验证二叉搜索树--搜索、回溯、剪枝

class Solution {
public:
    long pre = LONG_MIN;
    bool isValidBST(TreeNode* root) {
        if(root == nullptr) return true;
        bool left = isValidBST(root->left);
        if(!left) return false;
        bool cur = false;
        if(root->val > pre)
        {
            cur = true;
            pre = root->val;
        }
        if(!cur) return false;
        bool right = isValidBST(root->right);
        return (left && cur && right);
    }
};